package com.file.service.Impl;

import com.file.mapper.RightsMapper;
import com.file.pojo.Rights;
import com.file.service.RightsService;
import com.file.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RightsServiceImpl implements RightsService {

    @Autowired
    private RightsMapper rightsMapper;

    @Override
    public List<Rights> list() {
        return null;
    }

    @Override
    public List<Rights> findRightsByParentId(int id) {
       List<Rights> list =rightsMapper.findRightsByParentId(0);

       //return rights;
       //List<Rights> list = rightsMapper.findRightsByParentId(rights);
        for ( Rights right : list ) {
//            List<Rights> children = rightsMapper.findRightsByParentId(right);
//            right.setChildren(children);
            List<Rights> rights2 =rightsMapper.findRightsByParentId(right.getId());
            right.setChildren(rights2);
        }
//        return list;
        return list;
   }
}
